const Mock = require('mockjs')
const Random = Mock.Random
const phonePrefix = ['132', '135', '189', '158', '136']
const index = Math.floor(Math.random() * phonePrefix.length)
const phone = phonePrefix[index] + Mock.mock(/\d{8}/)

// define data
const data = Mock.mock({
  'items|100': [{
    id: '@id',
    name: '@first @last',
    xh: Mock.Random.id(),
    sfz: Random.id(),
    email: '@email',
    phone: phone,
    address: `${Random.county()}-${Random.province()}-${Random.city()}`
  }]
})

module.exports = [
  {
    url: '/vue-admin-template/student/list',
    type: 'get',
    response: config => {
      const items = data.items
      return {
        code: 20000,
        data: {
          total: items.length,
          items: items
        }
      }
    }
  },
  {
    url: '/vue-admin-template/student/update',
    type: 'post',
    response: config => {
      return {
        code: 20000
      }
    }
  },
  {
    url: '/vue-admin-template/student/add',
    type: 'post',
    response: config => {
      return {
        code: 20000
      }
    }
  }
]

